package com.tjetc.service.impl;

import com.tjetc.entity.FriendLinks;
import com.tjetc.entity.SpcifyResults;
import com.tjetc.dao.SpcifyResultsDao;
import com.tjetc.entity.SpcifyShoes;
import com.tjetc.service.SpcifyResultsService;
import com.tjetc.util.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.LazyInitializationExcludeFilter;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * 定制结果表(SpcifyResults)表服务实现类
 *
 * @author makejava
 * @since 2025-09-13 16:06:07
 */
@Service("spcifyResultsService")
public class SpcifyResultsServiceImpl implements SpcifyResultsService {
    @Resource
    private SpcifyResultsDao spcifyResultsDao;



    @Override
    public Object queryByPage(String name, Integer pageNum, Integer pageSize) {
        //查询总记录数
        Integer recordCount = spcifyResultsDao.count(name);
        System.out.println("--------------"+recordCount);
        //构建分页信息对象
        Pager pager = new Pager(pageNum, pageSize, recordCount);
        //根据pager查询需要的数据
        List<SpcifyResults> list = spcifyResultsDao.query(name,pager.getStart(), pageSize);
        //将分页信息和查询到的数据一起返回到前端
        HashMap<String,Object> map = new HashMap<>();
        map.put("pager",pager);
        map.put("list",list);
        return map;
    }

    @Override
    public void deleteById(Long id) {
        this.spcifyResultsDao.deleteById(id);
    }

    @Override
    public void updateById(SpcifyResults spcifyResults) {
        this.spcifyResultsDao.updateById(spcifyResults);
    }
}
